import { upload as normalUpload } from './normalUpload';
import { upload as obsUpload } from './obsUpload';
import { upload as ossUpload } from './ossUpload';
import { upload as s3Upload } from './s3Upload';
import { ObjectStorageType, uploadArgumentsType } from '../type';

// upload 工厂中转
export function uploadFactor(params: uploadArgumentsType) {
  let { bucketName, uploadType, instance, params: uploadParams } = params;
  switch (uploadType) {
    case ObjectStorageType.NORMAL:
      return normalUpload(uploadParams);

    case ObjectStorageType.OBS:
      return obsUpload(instance, uploadParams, bucketName);

    case ObjectStorageType.OSS:
      return ossUpload(instance, uploadParams);

    case ObjectStorageType.MINIO:
    case ObjectStorageType.AWS:
      return s3Upload(instance, uploadParams, bucketName);
  }
}
